package code.generate.bean;

import java.io.Serializable;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;

/**
 * @author "Jiance Qin"
 *
 * @date 2014年7月14日
 *
 * @time 下午4:20:45
 *
 * @desc 
 *
 */
public class Column implements Serializable {

	private static final long serialVersionUID = 5057736538326838020L;

	public static final Map<Integer, String> TYPE_MAP = new HashMap<Integer, String>() {

		private static final long serialVersionUID = -6147142461404708391L;

		{
			this.put(Types.DATE, "Date");
			this.put(Types.TIME, "Date");
			this.put(Types.TIMESTAMP, "Date");
			this.put(Types.INTEGER, "Long");
			this.put(Types.TINYINT, "Integer");
			this.put(Types.SMALLINT, "Integer");
			this.put(Types.VARCHAR, "String");
			this.put(Types.CHAR, "String");
			this.put(Types.LONGNVARCHAR, "String");
			this.put(Types.LONGVARCHAR, "String");
			this.put(Types.BIT, "String");
			this.put(Types.FLOAT, "Double");
			this.put(Types.REAL, "Double");
			this.put(Types.DOUBLE, "Double");
			this.put(Types.BIGINT, "Long");
			this.put(Types.BIT, "Integer");
			this.put(Types.BOOLEAN, "Boolean");
			this.put(Types.DECIMAL, "Double");
			this.put(Types.BLOB, "String");
		}
	};

	private String name;

	private String dbName;

	private String type;

	private String dbType;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public void setTypeId(Integer type) {
		this.type = TYPE_MAP.get(type);
		if (this.type == null)
			System.out.println("TypeException: type=" + type);
	}

	public String getDbName() {
		return dbName;
	}

	public void setDbName(String dbName) {
		this.dbName = dbName;
	}

	/**
	 * @return the dbType
	 */
	public String getDbType() {
		return dbType;
	}

	/**
	 * @param dbType
	 *            the dbType to set
	 */
	public void setDbType(String dbType) {
		this.dbType = dbType;
	}

}
